/**
 * Extend Product Center javascript package
 */
var house = {
	/* global selector */
	baseUrl : 'index.php',
	modeName : '',
	control	 : '',
	action	 : '',
	
	init : function(name,control,action){
		this.modeName = name;
		this.control = control;
		this.action = action;
		this.baseUrl += '?m='+name+'&c='+control+'&a='+action;
	},
	
	$ : function(id){
		return getObj(id);
	},
	
	/* ajax post submit */
	post : function(url,data,callback,sCallback,fCallback,isTips){
		var _this = this;
		ajax.send(url,data,function(){
			callback ? callback() : 0;
			isTips ?  0 : _this._showMessage(ajax.request.responseText,sCallback,fCallback);
		});
	},
	
	/* ajax send submit */
	send : function(url,data,callback){
		ajax.send(url,data,callback);
	},
	
	/* private show message include success and fail */
	_showMessage : function(txt,sCallback,fCallback){
		if(!txt || txt.indexOf('{') == '-1' ) return false;
		var r = JSONParse(txt);
		if(r.bool){
			this.showSuccessTips(r.message);
			sCallback ? sCallback() : 0;
		}else{
			this.showFailTips(r.message);
			fCallback ? fCallback() : 0;
		}
	},
	/* ajax get */
	get : function(url,data,id){
		sendmsg(url,data,id);
		
	},
	/* ajax submit */
	submit : function(obj,recall){
		ajax.submit(obj,recall);
	},
	/* show dialog */
	tips : function(type,message,autohide,callback){
		showDialog(type,message,autohide,callback);
	},
	/* get object position*/
	position : function(){
		
	},
	/* check All */
	CheckAll : function(form,obj){
		var checkBox = form.rids;
		if(checkBox.value){
			obj.checked ? checkBox.checked = true : checkBox.checked = false;
		}else{
			for (var i = 0; i < checkBox.length; i++) {	
				obj.checked ? checkBox[i].checked = true : checkBox[i].checked = false;
			}
		}
	},
	/* current tip */
	setCurrent : function(src,dst,css){
		setCurrent(src,dst,css);
	}
}

